package cc.rengu.redp.bizimpl.upmp.controller;

import cc.rengu.igas.momp.facade.request.QueryMemberDetailInfoRequest;
import cc.rengu.igas.momp.facade.request.QueryMemberInfoRequest;
import cc.rengu.redp.bizimpl.upmp.service.MemberManagerService;
import cc.rengu.redp.common.controller.BaseController;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 银行会员管理
 * </p>
 *
 * @author caoyanbin
 * @since 2021-11-22
 */
@Api(tags = "营销管理:银行会员管理")
@Slf4j
@RestController
@RequestMapping("/admin/market/memberManager/")
public class MemberManagerController extends BaseController {

	@Autowired
    MemberManagerService memberManagerService;

    /**
     * 获取首页list
     * @param request
     * @return
     */
    @RequiresPermissions("memberManager:list")
    @GetMapping("/getMemberList")
    public Map<String, Object> getMemberList(HttpServletRequest request, QueryRequest pageable) throws RedpException {
        QueryMemberInfoRequest param = new QueryMemberInfoRequest();
        param.setQueryType("0");
        param.setQueryRole("00");
        param.setMobileNo(request.getParameter("mobileNo"));
        param.setWechatOpenId(request.getParameter("wechatOpenId"));
        param.setAlipayUserId(request.getParameter("alipayUserId"));
        param.setCardNo(request.getParameter("cardNo"));

        return getDataTable(memberManagerService.getMemberList(param, pageable));
    }

    /**
     * 获取会员信息列表
     * @param request
     * @return
     */
    @RequiresPermissions("memberManager:view")
    @GetMapping("/getMemberDetailList")
    public Map<String, Object> getMemberDetailList(HttpServletRequest request, QueryRequest pageable) throws RedpException {
        QueryMemberDetailInfoRequest param = new QueryMemberDetailInfoRequest();
        param.setQueryType("0");
        param.setQueryRole("00");
        param.setMemberId(request.getParameter("memberId"));

        return getDataTable(memberManagerService.getMemberDetailList(param, pageable));
    }
}
